#!/usr/bin/env python
# coding=utf-8
# __author__ = 'Yunchao Ling'

from Bio import SeqIO
from Bio.SeqRecord import SeqRecord
from tqdm import tqdm

import os
import sys


def split_fasta(fasta_path: str, outpath: str):
    if not os.path.exists(outpath):
        os.mkdir(outpath)
    for seq_record in tqdm(SeqIO.parse(fasta_path, "fasta"), desc="seqs"):
        SeqIO.write(seq_record, os.path.join(outpath, seq_record.id + ".fasta"), "fasta")


if __name__ == '__main__':
    split_fasta(sys.argv[1], sys.argv[2])